package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
public class AdChannelController implements AdChannelControllerApi {

    @Autowired
    private AdChannelService channelService;

    @PostMapping("/list")
    @Override
    @ApiOperation(value = "查询频道信息",notes = "根据名称分页查询频道列表")
    @ApiImplicitParam(name = "dto",type = "ChannelDto",value = "查询名称",required = true)
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto){
        return channelService.findByNameAndPage(dto);
    }

    @PostMapping("/add")
    public ResponseResult addchanneldto(@RequestBody AdChannel channel){
        return  channelService.addchanneldto(channel);

    }

    @PostMapping("/deletebuId")
    @ApiOperation(value = "删除频道信息",notes = "根据名称分页查询频道列表")
    @ApiParam(name = "id",type = "Integer",value = "delete",required = true)
    public ResponseResult deletebyId(Integer id){
        return  channelService.deletebyId(id);
    }

    @PostMapping("/updateadchannel")
    public ResponseResult updateadchannel(@RequestBody AdChannel channel){
        return channelService.updateadchannel(channel);
    }

}
